# 注册用户
# curl -X POST http://localhost:5000/register -H "Content-Type: application/json" -d '{"username":"admin","password":"admin123","role":"admin"}'

# 登录获取 token
ACCESS_TOKEN=$(curl -s -X POST http://localhost:5000/login -H "Content-Type: application/json" -d '{"username":"admin","password":"admin123"}' | jq -r '.access_token')

# 添加权限策略
curl -X POST http://localhost:5000/add_policy -H "Content-Type: application/json" -H "Authorization: Bearer ${ACCESS_TOKEN}" -d '{"role":"user","resource":"data","action":"read"}'

# 访问受保护资源
curl http://localhost:5000/protected/data/read -H "Authorization: Bearer ${ACCESS_TOKEN}"